#!/bin/bash

echo "滚动更新开始 start"
#获取最新的镜像名称
KOALA_EURAKA_IMAGE=`cat $1/image_koala-euraka`
#替换运行中服务的镜像
echo "update image to deployments/koala-euraka-deployment koala-euraka:${KOALA_EURAKA_IMAGE}"
kubectl set image  deployments/koala-euraka-deployment koala-euraka=${KOALA_EURAKA_IMAGE} --namespace=$2
echo "update koala-euraka is ending"
sleep 30s
KOALA_CONFIG_IMAGE=`cat $1/image_koala-config`
echo "update image to deployments/koala-config-deployment koala-config:${KOALA_CONFIG_IMAGE}"
kubectl set image  deployments/koala-config-deployment koala-config=${KOALA_CONFIG_IMAGE} --namespace=$2
sleep 30s
KOALA_UPMS_IMAGE=`cat $1/image_koala-upms`
echo "update image to deployments/koala-upms-deployment koala-upms:${KOALA_UPMS_IMAGE}"
kubectl set image  deployments/koala-upms-deployment koala-upms=${KOALA_UPMS_IMAGE} --namespace=$2
sleep 40s
KOALA_AUTH_IMAGE=`cat $1/image_koala-auth`
echo "update image to deployments/koala-config-deployment koala-auth:${KOALA_AUTH_IMAGE}"
kubectl set image  deployments/koala-auth-deployment koala-auth=${KOALA_AUTH_IMAGE} --namespace=$2
sleep 20s
KOALA_GATEWAY_IMAGE=`cat $1/image_koala_gateway`
echo "update image to deployments/koala_gateway-deployment koala_gateway:${KOALA_GATEWAY_IMAGE}"
kubectl set image  deployments/koala_gateway-deployment koala_gateway=${KOALA_GATEWAY_IMAGE} --namespace=$2
echo "更新结束 end"
